<template>
  <div>
    <city-header></city-header>
    <city-search :searchData="searchData"></city-search>
    <city-list :cityData="fullCityData"></city-list>
  </div>
</template>

<script>
import CityHeader from './components/header'
import CitySearch from './components/search'
import CityList from './components/list'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList
  },
  data () {
    return {
      searchData: {},
      fullCityData: {}
    }
  },
  methods: {
    getCityData () {
      axios.get('/api/goodcity.json').then(this.getCityDataSucc)
    },
    getCityDataSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.searchData = data.cities
        this.fullCityData = data
      }
    }
  },
  mounted () {
    this.getCityData()
  }
}
</script>

<style lang="stylus" scoped>

</style>
